package com.xuyiwei.xblog.modular.system.warpper;

import com.xuyiwei.xblog.business.system.result.user.out.UserDto;
import com.xuyiwei.xblog.core.common.constant.factory.ConstantFactory;
import com.xuyiwei.xblog.core.base.warpper.BaseControllerWarpper;
import com.xuyiwei.xblog.core.support.StrKit;
import com.xuyiwei.xblog.core.util.OssUtil;

import java.util.List;
import java.util.Map;

/**
 * 用户管理的包装类
 *
 * @author fengshuonan
 * @date 2017年2月13日 下午10:47:03
 */
public class UserWarpper extends BaseControllerWarpper {

    public UserWarpper(List<UserDto> list) {
        super(list);
    }

    @Override
    public void warpTheMap(Map<String, Object> map) {
        String avatar = (String) map.get("avatar");
        if(StrKit.notBlank(avatar)){
            map.put("avatarImg", OssUtil.getUrl(avatar));
        }else{
            map.put("avatarImg", "");
        }
        map.put("sexName", ConstantFactory.me().getSexName((Integer) map.get("sex")));
        map.put("roleName", ConstantFactory.me().getRoleName((String) map.get("roleid")));
        map.put("deptName", ConstantFactory.me().getDeptName((Long) map.get("deptid")));
        map.put("statusName", ConstantFactory.me().getStatusName((Integer) map.get("status")));
        map.put("sourceName", ConstantFactory.me().getSourceName((String) map.get("source")));
    }

}
